package com.clear.honghefinance.biz.modules.system.menu.converter;

import com.clear.honghefinance.biz.modules.system.menu.domain.entity.SysMenu;
import com.clear.honghefinance.biz.modules.system.menu.domain.dto.CreateMenuDTO;
import com.clear.honghefinance.biz.modules.system.menu.domain.dto.UpdateMenuDTO;
import com.clear.honghefinance.biz.modules.system.menu.domain.vo.GetMenuByIdVO;
import com.clear.honghefinance.biz.modules.system.menu.domain.vo.ListTreeMenuVO;
import com.clear.honghefinance.biz.modules.system.menu.domain.vo.ListTreeSelectMenuVO;
import com.clear.honghefinance.biz.modules.system.role.domain.vo.ListRoleBindMenuVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface SysMenuConverter {

    SysMenuConverter INSTANCE = Mappers.getMapper(SysMenuConverter.class);

    GetMenuByIdVO convertSysMenuEntityToMenuByIdVO(SysMenu entity);

    SysMenu convertDTOToSysMenuEntity(CreateMenuDTO dto);

    SysMenu convertDTOToSysMenuEntity(UpdateMenuDTO dto);

    List<ListTreeMenuVO> convertSysMenuEntityListToListTreeMenuVOList(List<SysMenu> sysMenuList);

    @Mappings({
            @Mapping(target = "value", source = "id"),  // 菜单id
            @Mapping(target = "title", source = "name")  // 菜单名称
    })
    List<ListTreeSelectMenuVO> convertSysMenuEntityListToListTreeSelectMenuVOList(List<SysMenu> sysMenuList);

    List<ListRoleBindMenuVO> convertSysMenuEntityListToListRoleBindMenuVO(List<SysMenu> sysMenuList);
}
